<template>
  <div id="btn">
    <button @click="add">＋</button>
    <span>{{ count }}</span>
    <button @click="reduce">－</button>
  </div>
</template>

<script>
// import bus from "@/bus.js";
export default {
  methods: {
    add() {
      this.$emit("editCount", this.count + 1);
    },
    reduce() {
      var id = this.id;
      if (this.count == 0) return;
      else{
        var count = this.count - 1;
      }
       
      this.$emit("editCount", count);
    },
  },
  props: {
    id: {
      type: Number,
      require: true,
    },
    count: {
      type: Number,
      default: 0,
    },
  },
};
</script>

<style scoped lang="less">
#btn {
  width: 80px;
  // height: 30px;
  // background: yellow;
  span {
    display: inline-block;
    width: 20px;
    text-align: center;
  }
}
</style>